import 'package:flutter/material.dart';
import 'package:flutter_public/flutter_public.dart';

import '../a_start/start_page.dart';
import '../b_example/example_page.dart';
import '../c_public/flutter_public_page.dart';
import '../d_test/test_main_page.dart';

/// FileName main_page
///
/// @Author lax
/// @Date 2024/6/3
///
/// @Description

class MainPage extends StatefulWidget {
  const MainPage({super.key});

  @override
  State<StatefulWidget> createState() {
    return _MainPageState();
  }
}

class _MainPageState extends State<MainPage> {
  @override
  void initState() {
    super.initState();
    // 配置flutter_public
    PublicColor.appBar = Colors.lightGreen;
    PublicAppBar.defaultTitleStyle =
        BoldTextStyle(fontSize: 17, color: Colors.white);
    SectionHeader.defaultPadding = const EdgeInsets.symmetric(vertical: 12);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: body(),
    );
  }

  Widget body() {
    return Center(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          TextButton(
            onPressed: () {
              Navigator.push(
                context,
                MaterialPageRoute(builder: (_) {
                  return const StartPage();
                }),
              );
            },
            child: const Text('Flutter入门', textScaleFactor: 1.5),
          ),
          TextButton(
            onPressed: () {
              Navigator.push(
                context,
                MaterialPageRoute(builder: (_) {
                  return const ExamplePage();
                }),
              );
            },
            child: const Text('Flutter示例', textScaleFactor: 1.5),
          ),
          TextButton(
            onPressed: () {
              Navigator.push(
                context,
                MaterialPageRoute(builder: (_) {
                  return const FlutterPublicPage();
                }),
              );
            },
            child: const Text('Flutter组件', textScaleFactor: 1.5),
          ),
          TextButton(
            onPressed: () {
              Navigator.push(
                context,
                MaterialPageRoute(builder: (_) {
                  return const TestMainPage();
                }),
              );
            },
            child: const Text('Flutter实战', textScaleFactor: 1.5),
          ),
        ],
      ),
    );
  }
}
